namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0053 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.IcmInventoryStockTaking", "JobSiteId", "dbo.hrm_mp_job_sites");
            DropForeignKey("dbo.IcmInventoryStockTaking", "IcmWhId", "dbo.IcmWarehouse");
            DropIndex("dbo.IcmInventoryStockTaking", new[] { "JobSiteId" });
            DropIndex("dbo.IcmInventoryStockTaking", new[] { "IcmWhId" });
            AlterColumn("dbo.IcmInventoryStockTaking", "StockTakingStartDate", c => c.DateTime(nullable: false));
            AlterColumn("dbo.IcmInventoryStockTaking", "StockTakingDesc", c => c.String(nullable: false));
            AlterColumn("dbo.IcmInventoryStockTaking", "JobSiteId", c => c.Int(nullable: false));
            AlterColumn("dbo.IcmInventoryStockTaking", "IcmWhId", c => c.Int(nullable: false));
            AlterColumn("dbo.IcmInventoryStockTaking", "CreatedWhen", c => c.DateTime(nullable: false));
            AlterColumn("dbo.IcmDispose", "DisposeDesc", c => c.String(nullable: false));
            AlterColumn("dbo.IcmDispose", "DisposeDate", c => c.DateTime(nullable: false));
            AddForeignKey("dbo.IcmInventoryStockTaking", "JobSiteId", "dbo.hrm_mp_job_sites", "job_site_seq", cascadeDelete: true);
            AddForeignKey("dbo.IcmInventoryStockTaking", "IcmWhId", "dbo.IcmWarehouse", "WhId", cascadeDelete: true);
            CreateIndex("dbo.IcmInventoryStockTaking", "JobSiteId");
            CreateIndex("dbo.IcmInventoryStockTaking", "IcmWhId");
        }
        
        public override void Down()
        {
            DropIndex("dbo.IcmInventoryStockTaking", new[] { "IcmWhId" });
            DropIndex("dbo.IcmInventoryStockTaking", new[] { "JobSiteId" });
            DropForeignKey("dbo.IcmInventoryStockTaking", "IcmWhId", "dbo.IcmWarehouse");
            DropForeignKey("dbo.IcmInventoryStockTaking", "JobSiteId", "dbo.hrm_mp_job_sites");
            AlterColumn("dbo.IcmDispose", "DisposeDate", c => c.DateTime());
            AlterColumn("dbo.IcmDispose", "DisposeDesc", c => c.String());
            AlterColumn("dbo.IcmInventoryStockTaking", "CreatedWhen", c => c.DateTime());
            AlterColumn("dbo.IcmInventoryStockTaking", "IcmWhId", c => c.Int());
            AlterColumn("dbo.IcmInventoryStockTaking", "JobSiteId", c => c.Int());
            AlterColumn("dbo.IcmInventoryStockTaking", "StockTakingDesc", c => c.String());
            AlterColumn("dbo.IcmInventoryStockTaking", "StockTakingStartDate", c => c.DateTime());
            CreateIndex("dbo.IcmInventoryStockTaking", "IcmWhId");
            CreateIndex("dbo.IcmInventoryStockTaking", "JobSiteId");
            AddForeignKey("dbo.IcmInventoryStockTaking", "IcmWhId", "dbo.IcmWarehouse", "WhId");
            AddForeignKey("dbo.IcmInventoryStockTaking", "JobSiteId", "dbo.hrm_mp_job_sites", "job_site_seq");
        }
    }
}
